<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateTbAdUnmaskTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        if (!Schema::hasTable('tb_ad_unmask')) {
            Schema::create('tb_ad_unmask', function (Blueprint $table) {
                $table->integer('id')->autoIncrement();
                $table->integer('uid')->nullable()->default(0);
                $table->tinyInteger('status')->nullable()->default(0);
                $table->index('uid', 'idx_uid');
            });
            // \Hyperf\DbConnection\Db::select("CREATE TABLE IF NOT EXISTS `tb_ad_unmask_1` (
            // `id` int(11) NOT NULL AUTO_INCREMENT,
            // `uid` int(11) DEFAULT '0',
            // `status` tinyint(1) DEFAULT '0',
            // PRIMARY KEY (`id`) USING BTREE,
            // KEY `idx_uid` (`uid`) USING BTREE
            // ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC");
        }

    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('tb_ad_unmask');
        // \Hyperf\DbConnection\Db::select("DROP TABLE IF EXISTS tb_ad_unmask_1");
    }
}
